<?php
namespace Tool\tool;
use Model\SettingModel;

class Tool
{
    /**
     * 敏感关键词替换
     * @param $_content
     * @return string|string[]
     */
    static function sensitiveWord($_content)
    {
        global $_W;
        $_setting = SettingModel::where("uniacid",$_W["account"]["uniacid"])
            ->field(array("sensitive_word"))
            ->cache(!KUYUAN_DEBUG)
            ->find();
        if($_setting["sensitive_word"]) {
            $_sensitive_word = $_setting["sensitive_word"];
                $_replace = array();
                foreach($_sensitive_word as $_v) {
                    $_replace[] = str_repeat("*",mb_strlen($_v));
                }
                $_content = str_replace($_sensitive_word,$_replace,$_content);
        }
        return $_content;
    }
}